﻿using Jay.Sc2.Bof.Lib.State;

namespace Jay.Sc2.Bof.Lib.Action.Zerg
{
	public abstract class ActionProduceFromLarva : ActionProduceZerg
	{
		public ActionProduceFromLarva(int buildTime, int minerals, int gas, int food) : base(buildTime, minerals, gas, food) { }
		public abstract string EventName { get; }
		public virtual void OnProductionStarted(IBuildOrder bo) { }
		public abstract void OnProductionFinished(IBuildOrder bo);
		public override int AvailableProducer(IBuildOrder bo)
		{
			ZergState state = bo.State as ZergState;
			return state.Larva;
		}
		public override void Execute(IBuildOrder bo)
		{
			ZergState state = bo.State as ZergState;
			base.Execute(bo);
			state.UseLarva(bo);
			OnProductionStarted(bo);
			bo.AddAction(state.Time + BuildTime, new ActionGeneric(EventName, (ActionGeneric.ActionExecuteDelegate)delegate(IBuildOrder ibo)
			{
				ZergState ibostate = ibo.State as ZergState;
				OnProductionFinished(ibo);
			}));
		}
	}
}
